<template>
	<view class="search-wrapper">
		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input v-model="keyword" @input="inputKey" :adjust-position="false" type="text"
					placeholder="请输入2个及以上关键字查询" confirm-type="search" />
			</view>
			<view class="action" @click="handleSearch">
				<button class="cu-btn bg-green shadow-blur round">搜索</button>
			</view>
		</view>

		<view class="search-list font-35">
			<view class="" v-if="type==6">
				<view class="list-item zc-wrap-list" v-for="(item,index) in listData" :key="index"
					@click="selectData(item)">
					<view class="text-blue">
						名称：{{ item.VNAME || item.ZCMC }}
					</view>
					<view class="">
						编号： {{ item.ZCBH }}
					</view>
					<view class="">
						品牌： {{ item.PPXH }}
					</view>
					<view class="">
						部门：{{ item.BMMC }}
					</view>
					<!-- 查询供应商时显示账户 -->
					<view>{{ item.BILLNO }}</view>
				</view>
			</view>


			<view class="list-item flex-sb" v-else v-for="(item,index) in listData" :key="index"
				@click="selectData(item)">
				<!-- 查询货位时带出仓库显示 -->
				<view class v-if="item.STORENAME && type== 'BD_RACK' ">{{ item.STORENAME || '' }}</view>

				<view class="text-blue">
					<text v-if="item.ZCBH"> {{ item.ZCBH }} - </text>
					{{ item.FullName || item.VNAME || item.ZCMC ||  item.RealName ||item.text }}
				</view>

				<!-- 查询供应商时显示账户 -->
				<view>{{ item.BILLNO }}</view>
			</view>



		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from "vuex";
	import api from "../../common/api.js";
	import util from "../../common/util.js";
	let _self, searchUrl, urlParams, types, queryJson, CKType;
	export default {
		computed: mapState(["userInfo"]),
		data() {
			return {
				type: "",
				title: "",
				keyword: "",
				listData: [],
				i: "",
				organizeId: ""
			};
		},

		onLoad: function(params) {
			_self = this;
			let title = "查询";
			types = params.t;
			CKType = params.Btype
			_self.type = types;
			uni.setNavigationBarTitle({
				title: params.title + '列表'
			});
			_self.requestList("");
		},
		onShow: function() {},
		methods: {
			// ...mapMutations(['selectReduce']), // 引入 store 中的reduce方法
			inputKey: function(e) {
				let val = e.detail.value;
				if (val.length > 1) {
					this.requestList(val);
				}
			},
			handleSearch() {
				_self.requestList(_self.keyword);
				// console.log(_self.keyword);
			},
			selectData(e) {
				uni.navigateBack({});
				setTimeout(() => {
					uni.$emit("getSelectItemGS", {
						...e,
						TYPE: types
					});
				}, 500)
			},
			requestList(keyword) {
				let URL = "/api/APPExtend/GetProjects"
				let query = {
					type: types,
					Name: keyword
				}

				if (types == 5) { // 说明是业务类型查询
					URL = "/api/APPExtend/GetBillType"
					query.type = CKType == 5 ? '209' : 207
				}

				if (types == 6) { // 说明是 资产 查询
					URL = "/api/APPCommon/GetGDZCData"
					query.PK_ORG = ''
					query.type = ''
					query.NAME = ''
				}
				// console.log(URL,query );
				this.axios({
						url: URL,
						data: query,
						isLoading: 1
					})
					.then((res) => {
						console.log(res);
						_self.listData = res.Result;
					})
			}

		}
	};
</script>

<style scoped>
	.search-wrapper {}

	.search-list {
		background-color: #ffffff;
		margin-top: 20upx;
	}

	.list-item {
		padding: 20upx;
		border-bottom: 1px solid #dbdbdb;
		display: flex;
		justify-content: space-between;
		font-size: 35rpx;
	}

	.zc-wrap-list {
		flex-direction: column;
	}

	.list-item:active {
		background-color: #ededed;
	}
</style>